package com.ruoyi.system.service.impl;

import java.util.HashMap;
import java.util.List;
import com.ruoyi.common.core.utils.DateUtils;
import com.ruoyi.system.api.domain.SysUser;
import com.ruoyi.system.service.ISysDeptService;
import com.ruoyi.system.service.ISysUserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.ShAppointmentMapper;
import com.ruoyi.system.domain.ShAppointment;
import com.ruoyi.system.service.IShAppointmentService;

/**
 * 店铺预约信息Service业务层处理
 * 
 * @author ruoyi
 * @date 2023-08-10
 */
@Service
public class ShAppointmentServiceImpl implements IShAppointmentService 
{
    @Autowired
    private ShAppointmentMapper shAppointmentMapper;

    @Autowired
    private ISysDeptService sysDeptService;

    @Autowired
    private ISysUserService sysUserService;

    /**
     * 查询店铺预约信息
     * 
     * @param id 店铺预约信息主键
     * @return 店铺预约信息
     */
    @Override
    public ShAppointment selectShAppointmentById(Long id)
    {
        return shAppointmentMapper.selectShAppointmentById(id);
    }

    /**
     * 查询店铺预约信息列表
     * 
     * @param shAppointment 店铺预约信息
     * @return 店铺预约信息
     */
    @Override
    public List<ShAppointment> selectShAppointmentList(ShAppointment shAppointment)
    {
        HashMap<Long, String> schoolMap = sysDeptService.getShopMap();
        HashMap<Long, SysUser> userNameMap = sysUserService.getUserMap();
        List<ShAppointment> list = shAppointmentMapper.selectShAppointmentList(shAppointment);
        for (ShAppointment obj : list) {
            if (null!=schoolMap) {
                obj.setShopName(schoolMap.get(obj.getShopId()));
            }
            if (null!=userNameMap) {
                SysUser userParam = userNameMap.get(obj.getCreateBy());
                obj.setCreateByName(userParam.getUserName());
            }
        }
        return list;
    }

    /**
     * 新增店铺预约信息
     * 
     * @param shAppointment 店铺预约信息
     * @return 结果
     */
    @Override
    public int insertShAppointment(ShAppointment shAppointment)
    {
        shAppointment.setCreateTime(DateUtils.getNowDate());
        return shAppointmentMapper.insertShAppointment(shAppointment);
    }

    /**
     * 修改店铺预约信息
     * 
     * @param shAppointment 店铺预约信息
     * @return 结果
     */
    @Override
    public int updateShAppointment(ShAppointment shAppointment)
    {
        return shAppointmentMapper.updateShAppointment(shAppointment);
    }

    /**
     * 批量删除店铺预约信息
     * 
     * @param ids 需要删除的店铺预约信息主键
     * @return 结果
     */
    @Override
    public int deleteShAppointmentByIds(Long[] ids)
    {
        return shAppointmentMapper.deleteShAppointmentByIds(ids);
    }

    /**
     * 删除店铺预约信息信息
     * 
     * @param id 店铺预约信息主键
     * @return 结果
     */
    @Override
    public int deleteShAppointmentById(Long id)
    {
        return shAppointmentMapper.deleteShAppointmentById(id);
    }
}
